package com.org.gundutubruk;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MultiPlayerActivity extends Activity {
	
	private MultiPlayerActivity self;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) { 
		super.onCreate(savedInstanceState);
		self = this; 
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);		
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		setContentView(R.layout.create_or_join);
		Button joinGame = (Button) this.findViewById(R.id.joinGame);
		Button createGame = (Button) this.findViewById(R.id.createGame);
		Button help = (Button) this.findViewById(R.id.help);
		joinGame.setOnClickListener(new OnClickListener() {
		    @Override
			public void onClick(View v) {		   		    	                
		    	Intent clientIntent = new Intent(self, SelectClientPlayerActivity.class);
		    	clientIntent.putExtra("TYPE", 1);//sebagai client
                startActivity(clientIntent);
				overridePendingTransition(R.anim.fade, R.anim.hold);
		    }
		});
		createGame.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {								
				Intent serverIntent = new Intent(self, SelectClientPlayerActivity.class);
		    	serverIntent.putExtra("TYPE", 0);//sebagai server
				startActivity(serverIntent);
				overridePendingTransition(R.anim.fade, R.anim.hold);												
			}
		});
		help.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				AlertDialog.Builder builder = new AlertDialog.Builder(self);
				builder.setMessage(R.string.bluetooth_help)
				       .setCancelable(true)
				       .setPositiveButton("Oke", new DialogInterface.OnClickListener() {
				           public void onClick(DialogInterface dialog, int id) {
				                dialog.cancel();
				           }
				       });				       
				AlertDialog alert = builder.create();
				alert.show();
			}
		});
	}
	
	@Override
	public void onBackPressed() {
		this.startActivity(new Intent("android.intent.action.GAMEMODE"));
		overridePendingTransition(R.anim.fade, R.anim.hold);		
		this.finish();
	}
}
